/**
 * 提示框
 * Created by zhaijg.
 */
'use strict';
angular.module('app')
    .factory('messageServices', ['$modal','$state', function ($modal,$state) {
        return {
            //打开上传mode
            openShowMessage: function (title, info,goPath) {
                var modalInstance = $modal.open({
                    templateUrl: 'tpl/modal/message.html',
                    controller: 'messageCtrl',
                    size: 'sm',
                    resolve: {
                        title: function () {
                            return title;
                        },
                        info: function () {
                            return info;
                        }
                    }
                });
                //操作返回
                if(goPath!=null&&goPath!=undefined){
                    //操作返回
                    return modalInstance.result.then(function (selectedItem) {
                        // 清空用户本地token存储的信息，如果
                        if(goPath!=""){
                            $state.go(goPath);//跳转到登录界面
                            return;
                        }
                    }, function () {
                        if(goPath!=""){
                            $state.go(goPath);//跳转到登录界面
                            return;
                        }
                    });
                }else{
                    return modalInstance.result;
                }

            }
        }
    }]);
app.controller('messageCtrl', ['$scope', '$modalInstance','title','info',
    function ($scope, $modalInstance,title,info) {
        $scope.message_title = title;
        $scope.message_info = info;
        //点确认按钮关闭
        $scope.ok = function () {
            $modalInstance.close();
        };
        //取消按钮
        $scope.cancelModal = function () {
            $modalInstance.dismiss('cancel');
        };
    }]);